package com.cabal.common.util;

import org.apache.commons.lang.ArrayUtils;

/**
 * 手机号工具类
 *
 * @author shenkang
 * @date 2022年11月24日
 */
public class TmsPhoneUtil {

	public static final String[] PHONE_CHINA_INTER_CROWN_NUMBER = {"+86-", "86-", "+86-", "+86", "+86 ", "+","86 ", "0086"};

	/**
	 * 删除中国国际冠号
	 * 
	 * @param phoneNum 手机号
	 * @return
	 */
	public static String delChinaInterCrownNumber(String phoneNum){
		if(ArrayUtils.isEmpty(PHONE_CHINA_INTER_CROWN_NUMBER)){
			return phoneNum;
		}
		for (String rMobileICNum : PHONE_CHINA_INTER_CROWN_NUMBER) {
			if(phoneNum.startsWith(rMobileICNum)){
				phoneNum = phoneNum.replace(rMobileICNum, "").trim();
				break;
			}
		}
		return phoneNum;
	}
	
	public static void main(String[] arg0){
		//如果收件人手机号前面出现"+86"、"+86-"、"+86 ",则替换为""
		String phoneNum = "86-15711956607";
		phoneNum = TmsPhoneUtil.delChinaInterCrownNumber(phoneNum);
		System.out.println("phoneNum-->"+phoneNum);
	}
}
